import type { Channel } from '../../types/channel'
/**
 *
 * @param state 初始化或是上一次的值
 * @param action 触发的action
 *               我们这里的action，有两个属性
 *               {type: 'channel/setChannels',payload: Channel[]}
 */
const channelReducer = (
  state = [] as Channel[],
  action: { type: 'channel/setChannels'; payload: Channel[] }
) => {
  console.log('---channelReducer---')
  switch (action.type) {
    case 'channel/setChannels':
      return action.payload

    default:
      return state
  }
}

export default channelReducer
